<template>
    <div class="admin-container">
      <el-config-provider>
        <router-view v-slot="{ Component }">
          <transition name="fade" mode="out-in">
            <component :is="Component" />
          </transition>
        </router-view>
      </el-config-provider>
    </div>
  </template>
  
  <script setup>
  import { onMounted, onUnmounted } from 'vue'
  import { useRouter } from 'vue-router'
  
  const router = useRouter()
  
  // 检查登录状态
  onMounted(() => {
    const token = localStorage.getItem('admin_token')
    if (!token && router.currentRoute.value.path !== '/login') {
      router.push('/login')
    }
  })
  
  // 清理工作
  onUnmounted(() => {
    // 如有需要，可在此处添加清理代码
  })
  </script>
  
  <style>
  .admin-container {
    height: 100vh;
    width: 100vw;
  }
  
  .fade-enter-active,
  .fade-leave-active {
    transition: opacity 0.3s;
  }
  
  .fade-enter-from,
  .fade-leave-to {
    opacity: 0;
  }
  </style>